/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.dao;

import com.metier.*;
import com.ihm.*;
import java.util.*;
import java.sql.*;
import java.io.*;
import javax.swing.*;

public class HistoriquePreparedRequete
{

    private PreparedStatement ps;
    private Connecter connector;
    private JDialog dialogerreur;
    private ResultSet rs;
    private static String date;
    private static ArrayList<String> Datelist;  
    private static ArrayList<String> description;
    
    /* @Setter DateList */
    public void setDatelist(ArrayList<String> date) {
        Datelist = date;
    }
    
    /* @Getter Dae */
    public static ArrayList<String> getDatelist()
    {
        return Datelist;
    }

    /* @Setter Description */
    public static void setDescription(ArrayList<String> description)
    {
        HistoriquePreparedRequete.description = description;
    }
    
    /* @Getter Description */
    public static ArrayList<String> getDescription() {
        return description;
    }

    public HistoriquePreparedRequete()
    {
        connector = new Connecter();
    }
   
    /* Requête pour afficher la liste de l'historique */
    public void afficher() throws SQLException
    {
        Datelist = new ArrayList<>();
        description = new ArrayList<>();
        String sql = "SELECT * FROM historique ORDER by ID_Historique DESC";
        ps = connector.getConnection().prepareStatement(sql);
        rs = ps.executeQuery();
        while(rs.next())
        {
                Datelist.add(rs.getTimestamp("DateAction").toString());
                description.add(rs.getString("DescriptionAction"));
        }
        ps.close();
     }
}
